package lab02.Test28;
import java.util.InputMismatchException;
import java.util.Scanner;
/**
 * Created by lady on 2017/12/14.
 */
public class Test {
    public static void main(String[] args) {
        //要求从键盘输入一个double类型的圆的半径，计算并输出其面积
        double radius;
        double area;
        Scanner scanner = new Scanner(System.in);
        System.out.println("please input radius:");
        try {
            radius = scanner.nextDouble();
            area = calArea(radius);
            System.out.println("The circle area: " + area);
        } catch (InputMismatchException e) {
            System.out.println("半径不是double类型数据！");
        }
    }
    //计算面积 ，输入：半径，返回：面积大小

    public static double calArea(double radius) {
        double area = 3.14 * radius * radius;
        return area;
    }
}
